package com.zdw.test2;

import com.zdw.test2.utils.JdbcUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * Author: Zhang Dongwei
 * Date: 2022/4/3 19:41
 */
public class TestDelete {
    public static void main(String[] args) {
        Connection conn=null;
        Statement st=null;
        ResultSet rs = null;
        try {
            conn = JdbcUtils.getConnection(); //获取数据库链接
            st = conn.createStatement();//获取sql执行对象

            String sql="DELETE from `users` WHERE id = 4"; // 其他都不用变，只要修改SQL即可

            int i = st.executeUpdate(sql);
            if(i>0) System.out.println("删除成功");
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            JdbcUtils.release(conn,st,null);
        }
    }
}
